public class B {
    public static void main(String[] args) {
        String s =  "Hello, my name is John";
        int str = 0;
        for (int i = 0; i < s.length(); i++) {
            if ((i == 0 || s.charAt(i - 1) == ' ') && s.charAt(i) != ' ') {
                str++;
            }
        }
        System.out.println(str);
    }
}
